package com.heyqing.topic.Intersection_0349;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.IntFunction;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * ClassName:Intersection
 * Package:com.heyqing.topic.Intersection_0349
 * Description:
 *
 * @Date:2024/9/27
 * @Author:Heyqing
 */
public class Intersection {
    public int[] intersection(int[] nums1, int[] nums2) {
        List<Integer> num1List = Arrays.stream(nums1).boxed().collect(Collectors.toList());
        return Arrays.stream(nums2)
                .filter(n2 -> num1List.contains(n2))
                .boxed().collect(Collectors.toSet())
                .stream()
                .mapToInt(Integer::intValue)
                .toArray();
    }
}
